using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Xml.Serialization;

namespace Trentacular.SharePoint.Features.Web.UI.WebParts
{
    [Guid("aec79f30-c441-4b33-b1a9-bef457cd952a")]
    [XmlRoot(Namespace = "Trentacular.SharePoint.Features.Web.UI.WebParts.SPControlWrapperWebPart")]
    public class SPControlWrapperWebPart : ControlWrapperWebPart
    {
        protected override void CreateChildControls()
        {
            if (string.IsNullOrEmpty(WrappedUserControlVirtualPath))
            {
                Controls.Add(new LiteralControl(
                    string.Format("Configure the virtual path to the user control to wrap in the {0}",
                        GetToolPaneLink("tool pane")
                        )
                    ));
            }
            else
            {
                base.CreateChildControls();
            }
        }

        protected string GetToolPaneLink(string msg)
        {
            return string.Format("<a href=\"javascript:MSOTlPn_ShowToolPane2('Edit','{0}');\">{1}</a>", this.ID, msg);
        }
    }
}
